package com.rzt.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Map工具类
 *
 * @author Zhao Yi
 * @version 1.0
 * @date 2020/12/30 15:31
 **/
public class MapUtils {

    /**
     * map key转小写
     *
     * @param map
     * @param <V>
     * @return
     */
    public static <V> Map<String, V> toLowerCaseMap(Map<String, V> map) {
        Map<String, V> resultMap = new HashMap<>();
        Set<String> sets = map.keySet();
        for (String key : sets) {
            resultMap.put(key.toLowerCase(), map.get(key));
        }
        return resultMap;
    }

    /**
     * map key转大写
     *
     * @param map
     * @param <V>
     * @return
     */
    public static <V> Map<String, V> toUpperCaseMap(Map<String, V> map) {
        Map<String, V> resultMap = new HashMap<>();
        Set<String> sets = map.keySet();
        for (String key : sets) {
            resultMap.put(key.toLowerCase(), map.get(key));
        }
        return resultMap;
    }

}
